#include "Comm.hpp"

int main()
{
    int wfd = open(Path, O_WRONLY);//写方式打开
    if(wfd < 0)// 打开失败
    {
        cout << "open failed, errno: " << errno << ", errstring: " << strerror(errno) <<  endl;
    }
    string inbuffer;
    while(true)
    {
        cout << "Please Enter your Message# ";
        getline(cin,inbuffer);
        // 发生信息,调用write接口
        if(inbuffer == "quit") break;
        ssize_t n = write(wfd, inbuffer.c_str(), inbuffer.size());
        if(n < 0)
        {
            cout << "write failed, errno: " << errno << ", errstring: " << strerror(errno) <<  endl; 
            break;
        }
           
    }
    close(wfd);//关掉管道的写端
    return 0;
}

